<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WebSocket</title>
</head>
<body>
    <script>
        var wsServer = "ws://127.0.0.1:9503"；
        var ws = new WebSocket(wsServer);

        ws.onopen = function(event) {
            console.log("连接成功");
            // ws.send("hello");
            // console.log("发送数据");
            // ws.close();
            // console.log("关闭连接");
        };

        ws.onmessage = function(event) {
            console.log("收到数据");
            console.log(event);
            console.log(event.data);
            console.log(event.data.length);
            console.log(event.data[0]);
            console.log(event.data[1]);
        }

        ws.onclose = function(event) {
            console.log("关闭连接");
        }

        ws.onerror = function(event) {
            console.log("连接出错");
        }


    </script>
</body>
</html>